<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript" src="../js/vue.js"></script>
</head>
<body>
    <style>
        *{
            margin: 20px;
        }
    </style>

    <div id="root">
        <h1>您好，{{name}}</h1>
        <!-- 
            prevent 阻止默认事件
            stop 阻止冒泡事件
            once 事件只触发一次
         -->
        <a href="http://www.baidu.com" @click.prevent="showInfo">点我提示信息!!!</a>

        <div @click="showInfo">
            <button @click.stop="showInfo">点我提示信息</button>
        </div>

        <button @click.once="showInfo">点我提示信息</button>

        <div class="box1">
            div1
            <div class="box2">
                div2
            </div>
        </div>
    </div>

    <script>
        Vue.config.productionTip = false

        const x = new Vue({
            el:'#root', 
            data:{
                name:'魔法师'
            },
            methods: {
                showInfo(e){
                    //e.preventDefault();
                    
                    alert('同学您好');
                }
            },
        })
    </script>
</body>
</html>